package com.dwj;

import com.dwj.dao.BookDao;
import com.dwj.service.BookService;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class App {
    public static void main(String[] args) {
        // 3.获取IOC容器
        ApplicationContext ctx = new ClassPathXmlApplicationContext("applicationContext.xml");
        // 4. 获取bean
        BookDao bookDao1 = (BookDao) ctx.getBean("bookDao");
        BookDao bookDao2 = (BookDao) ctx.getBean("bookDao");
        bookDao1.save();

        BookService bookService = (BookService) ctx.getBean("bookService");
        bookService.save();
        System.out.println(bookDao1);
        System.out.println(bookDao2);
    }
}
